<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>权限编辑</title>
    <link rel="apple-touch-icon" sizes="120x120" href="favicon/apple-icon-120x120.png">
    <link rel="icon" type="image/png" sizes="192x192" href="favicon/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/animate.css/animate.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.css')) ?>">
    <link rel="stylesheet"
          href="<?php xcho(loadSource('/assets/plugins/data-table/media/css/dataTables.bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/style.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/app.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
    
    <style>
        .pagination{
            margin: 0;
        }
    </style>
</head>

<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>

<div class="wrap">
    <div class="page-body" style="padding: 0">
        <div class="content" style="margin: 0;background: #F4F4F4">
            <div class="content-cont">
                <div class="top_btn">
                    <button>批量修改分级</button>
                    <button>添加</button>
                </div>
                <div class="top_pages">
                    <p>已选择 2 项</p>
                    <ul>
                        <li>共搜索到 922 条数据</li>
                        <li><</li>
                        <li>1</li>
                        <li>2</li>
                        <li>3</li>
                        <li>4</li>
                        <li>5</li>
                        <li>6</li>
                        <li>7</li>
                        <li>8</li>
                        <li>9</li>
                        <li>></li>
                        <li>跳至<input type="text">页</li>
                    </ul>
                </div>
                <div class="table">
                    <table>
                        <thead>
                        <tr>
                            <th><span id="checkAll"><b>-</b></span>名称</th>
                            <th>分级</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td><input type="checkbox" name="ck">官网</td>
                            <td>
                                <select name="" id="">
                                    <option value="">十级</option>
                                </select>
                            </td>
                            <td><span>编辑</span><span>转移</span><span>删除</span></td>
                        </tr>
                        <tr>
                            <td><input type="checkbox" name="ck">市场</td>
                            <td>
                                <select name="" id="">
                                    <option value="">九级</option>
                                </select>
                            </td>
                            <td><span>编辑</span><span>转移</span><span>删除</span></td>
                        </tr>
                        <tr>
                            <td><input type="checkbox" name="ck">网络推广</td>
                            <td>
                                <select name="" id="">
                                    <option value="">一级</option>
                                </select>
                            </td>
                            <td><span>编辑</span><span>转移</span><span>删除</span></td>
                        </tr>
                        <tr>
                            <td><input type="checkbox" name="ck">渠道合作 - 学校</td>
                            <td>
                                <select name="" id="">
                                    <option value="">一级</option>
                                </select>
                            </td>
                            <td><span>编辑</span><span>转移</span><span>删除</span></td>
                        </tr>
                        <tr>
                            <td><input type="checkbox" name="ck">学员介绍</td>
                            <td>
                                <select name="" id="">
                                    <option value="">十级</option>
                                </select>
                            </td>
                            <td><span>编辑</span><span>转移</span><span>删除</span></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div class="top_pages bottom_pages">
                    <ul>
                        <li>共搜索到 922 条数据</li>
                        <li><</li>
                        <li>1</li>
                        <li>2</li>
                        <li>3</li>
                        <li>4</li>
                        <li>5</li>
                        <li>6</li>
                        <li>7</li>
                        <li>8</li>
                        <li>9</li>
                        <li>></li>
                        <li>跳至<input type="text">页</li>
                    </ul>
                </div>
            </div>
        </div>

    </div>
</div>
<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/jquery.dataTables.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/dataTables.bootstrap.min.js')) ?>"></script>
<script
    src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/dataTables.responsive.min.js')) ?>"></script>
<script
    src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/responsive.bootstrap.min.js')) ?>"></script>
<script>
    $(function () {


        "use strict";

        //TABLE
        $("#checkAll").click(function () {
            $("input[name='ck']").each(function () {
                if ($(this).prop("checked")) {
                    $(this).prop("checked", false);
                }
                else {
                    $(this).prop("checked", "true");
                }
            })
        });
//        function selectAll(){
//            if ($("#SelectAll").attr("checked")) {
//                $(":checkbox").attr("checked", true);
//            } else {
//                $(":checkbox").attr("checked", false);
//            }
//        }
        $("#read_messages").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
                var id = $(this).val();
                $("tbody tr").each(function () {
                    console.log('$(this).attr("data-messageid")===' + $(this).attr("data-r"))
                    if ($(this).attr("data-r") == id) {
                        $(this).find("i.fa-envelope").fadeOut();
                    }
                });
                $(".set_read").each(function () {
                    console.log('$(this).attr("data-messageid")===' + $(this).attr("data-r"))
                    if ($(this).attr("data-messageid") == id) {
                        $(this).fadeOut();
                    }
                });
            });
            console.info(ids);
            if (ids.length == 0) {
                alert("至少选择一项");
            } else {
                $.ajax({
                    url: "/index/message/batchIsRead",
                    data: {
                        ids: ids,
                        read_status: "is_read"
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        console.log(data)
                        if(data.success == 1){
                            $("#no_read_message").html(data.count.noMsg);
                            $("#all_message").html(data.count.totalMsg);
                        }else{

                        }
                    },
                    complete:function(){
                        location.reload();
                    },
                    error: function () {

                    }
                });
            }

        });
        $("#del_messages").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
                var id = $(this).val();
                $("tbody tr").each(function () {
                    console.log('$(this).attr("data-messageid")===' + $(this).attr("data-r"))
                    if ($(this).attr("data-r") == id) {
                        $(this).fadeOut();
                    }
                });
            });
            console.info(ids);
            if (ids.length == 0) {
                alert("至少选择一项");
            } else {
                $.ajax({
                    url: "/index/message/delLetter",
                    data: {
                        ids: ids,
                        read_status: "is_read"
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        console.log(data)
                        if(data.success == 1){
                            $("#no_read_message").html(data.count.noMsg);
                            $("#all_message").html(data.count.totalMsg);
                        }else{

                        }
                    },
                    complete:function(){
                        location.reload();
                    },
                    error: function () {

                    }
                });
            }

        });
        $(".set_read").on("click", function () {
            console.log($(this).attr("data-messageid"));
            var id = $(this).attr("data-messageid");
            var ids = [];
            ids.push(id);
            $.ajax({
                url: "/index/message/batchIsRead",
                data: {
                    ids: ids,
                    read_status: "is_read"
                },
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    console.log(data)
                    if(data.success==1){
                        $("tbody tr").each(function () {
                            console.log('$(this).attr("data-messageid")===' + $(this).attr("data-r"))
                            if ($(this).attr("data-r") == id) {
                                $(this).find("i.fa-envelope").fadeOut();
                            }
                        });
                        $(".set_read").each(function () {
                            console.log('$(this).attr("data-messageid")===' + $(this).attr("data-r"))
                            if ($(this).attr("data-messageid") == id) {
                                $(this).fadeOut();
                            }
                        });
                        if(data.success == 1){
                            $("#no_read_message").html(data.count.noMsg);
                            $("#all_message").html(data.count.totalMsg);
                        }else{

                        }
                    }
                },
                complete:function(){
                    location.reload();
                },
                error: function () {

                }
            });
        })
        $('.del_message').on("click", function () {
            console.log($(this).attr("data-messageid"));
            var ids = [];
            var id = $(this).attr("data-messageid");
            ids.push($(this).val());
            $.ajax({
                url: "/index/message/delLetter",
                data: {
                    ids: id,
                    read_status: "is_read"
                },
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                    if (data.success) {
                        $("tbody tr").each(function () {
                            console.log('$(this).attr("data-messageid")===' + $(this).attr("data-r"))
                            if ($(this).attr("data-r") == id) {
                                $(this).fadeOut();
                            }
                        });
                        if(data.success == 1){
                            $("#no_read_message").html(data.count.noMsg);
                            $("#all_message").html(data.count.totalMsg);
                        }else{

                        }
                    } else {
                        alert("删除失败,请刷新重试!")
                    }

                },
                complete:function(){
                  location.reload();
                },
                error: function () {

                }
            });

        });
        $("input[type='checkbox']").on("click", function () {
            var shecked_length = $("input[name='ck']:checked").length;

        });


    });
</script>
<?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>
<button id="top" style="height: 50px;width: 50px;"></button></body>

</html>
